<template>
	<view class="mains">
		<!-- <back-fixed title="患者详情" urlBack="/pages/patient/index"></back-fixed> -->
		<view class="huanzhedetail">
			<view class="pepinfo">
				<view class="pepinfomain">
					<p class="pepname">{{showName}}<span v-if="data.type">@{{data.type}}</span></p>
					<view class="pepmiaoshu">
						<!-- 性别和年龄都为空时候整个地方不显示 -->
						<view class="pepage" v-if="!(data.sex == '2' && data.age == 0)">
							<view class="sexlogo" v-if="data.sex !== '2'">
								<image :src="data.sex=='0' ? Male : Female " mode=""></image>
							</view>
							<view class="agenum" v-if="data.age && data.age !== 0">
								{{data.age}}岁
							</view>
						</view>
						<view class="suoshu">
							主治医生：{{data.createUserName}}
						</view>
					</view>
					<view class="juti" v-show="data.createUserName">
						<!-- 2024.06.18 11:08:14 患者通过 扫描二维码 的方式添加 闫艳丽 -->
						{{data.createTime ? data.createTime : '' }}患者通过<span
							style="color: #4DC0D9;padding: 0 10px">{{data.addWay}}</span> 的方式添加 <span
							style="color: #4DC0D9;padding: 0 10px">{{data.createUserName ?data.createUserName : '' }}</span>
						<!-- {{data.createTime ? data.createTime : '' }} 由 <span>
							{{data.createUserName ?data.createUserName : '' }} </span> 通过患者 <span> 扫描二维码 </span> 的方式添加 -->
					</view>
				</view>
			</view>
			<view class="biaoqian">
				<view class="biaoqianmain">
					<view class="biaoqiantop">
						<view class="biaoqiantopl">
							标签
						</view>
						<view class="biaoqiantopr" @click.capture="openMarkList">
							<view class="biaoqiantoprtit">
								打标签
							</view>
							<view class="biaoqiantoprlogo">
								<!-- <u-icon name="arrow-right" color="#ccc"></u-icon> -->
							</view>
						</view>
					</view>
					<view class="" style="width: 92.5%;margin: 0 auto;">
						<u-read-more :show-height="180" openText=" " :toggle="true" closeText=" "
							:shadow-style="shadowStyle">
							<ul class="zhingkeitemlist" style="list-style: none;margin: 0;padding: 0;">
								<li class="zhingkeitemname" style="float: left;list-style: none;"
									v-for="it,key in lists" :key="key">
									{{it.name}}
								</li>
							</ul>
						</u-read-more>
					</view>
				</view>
			</view>
			<view class="biaoqian">
				<view class="biaoqianmain">
					<!-- <view class="biaoqiantop">
						<view class="biaoqiantopl">
							基础信息
						</view>
						<view class="biaoqiantopr" @click="dengji">
							<view class="biaoqiantoprtit">
								
							</view>
							 <view class="biaoqiantoprlogo" @click="getContexts">
								收集
							</view> 
						</view>
					</view> -->
					<view class="nav_list">
						<u-tabs :list="listNav" :is-scroll="false" :current="currentNav" :bold="false"
							@change="changeNav" font-size="34" height="90" active-color="#4DC0D9"
							bar-width="120"></u-tabs>
					</view>
					<view class="base" v-show="currentNav == 0">
						<view class="jichuitem">
							<view class="jichuiteml">
								姓名
							</view>
							<view class="jichuitemr">
								<!-- 张三丰 -->
								{{baseInfo.name ? baseInfo.name : '暂无'}}
							</view>
						</view>
						<view class="jichuitem">
							<view class="jichuiteml">
								手机号码
							</view>
							<view class="jichuitemr">
								<!-- 176*****187 phoneNum -->
								{{baseInfo.phone ? phoneNum(baseInfo.phone) : '暂无'}}
							</view>
						</view>
						<view class="jichuitem">
							<view class="jichuiteml">
								生日
							</view>
							<view class="jichuitemr">
								<!-- 19960816 -->
								{{baseInfo.birthday ? baseInfo.birthday : '暂无'}}
							</view>
						</view>
						<view class="jichuitem">
							<view class="jichuiteml">
								门诊号
							</view>
							<view class="jichuitemr">
								<!-- 1785269 -->
								暂无
							</view>
						</view>
						<view class="jichuitem">
							<view class="jichuiteml">
								居住地
							</view>
							<view class="jichuitemr">
								<!-- 河南省郑州市中原区秦岭路街道国棉一厂西六街8号楼2单元4楼西户 -->
								{{baseInfo.addressDetail ? baseInfo.addressDetail : '暂无'}}
							</view>
						</view>
						<view class="jichuitem">
							<view class="jichuiteml">
								描述
							</view>
							<view class="jichuitemr">
								暂无
							</view>
						</view>
					</view>

					<view class="jihua" v-show="currentNav == 1">
						<view class="rule_box" v-if="!JobEmpty">
							<view class="rule_card" v-for="(n,key) in jobList" :key="n.planId">
								<view class="rule_step">
									<view class="dot">
										<u-image :src="setpTime" width="24rpx" height="24rpx"></u-image>
										<view class="time_title">
											创建时间：
										</view>
										<view class="time_title">
											{{timeSerious(n.createTime)}}
										</view>
										<view class="stop" @click="stopProject(n)" v-if="[0,1].includes(n.planStatus)">
											<u-image :src="stop" width="40rpx" height="40rpx"></u-image>
										</view>
									</view>

									<view class="dash">

									</view>
								</view>
								<view class="rule_content">
									<view class="">
										<view class="rule_content_title">
											<view class="base_status"
												:class="{'blue':n.planStatus==1,'green':n.planStatus==2,'green':n.planStatus==-1}">
												{{state(n.planStatus)}}
											</view>
											<view class="m-l-10">
												{{cultString(n.planName,14)}}
											</view>
										</view>

										<!-- <view class="rule_content_details">
											{{cultString(n.jobContent,35)}}
										</view> -->
										<view class="" v-for="(value,keys) in n.followupPlanJobList" :key="value.id">
											<view class="card_inner_box" v-if="n.arrow == 'arrow-up'">
												<view class="card_inner_box_time">
													执行时间：{{timeSerious(value.jobStartTime)}}
												</view>
												<view class="card_inner_box_title">
													<view class="rule_content_title">
														<view class="base_icon zhouqi"
															:class="{'zhouqi':value.jobType == 2,'dingshi':value.jobType == 1}">
															{{value.jobType == 1 ? '定时' : '周期'}}
														</view>
														<view class="m-l-10">
															{{cultString(value.jobName,14)}}
														</view>
													</view>
												</view>
												<view class="card_inner_box_content">
													{{cultString(value.jobContent,16)}}
												</view>
												<view class="card_inner_box_action">
													<!-- quesStatus为1的时候,显示答卷 -->
													<view class="action_item" @click="look(value)" v-if="[1,2].includes(value.quesStatus)">
														查看问卷
													</view>
													<!-- quesStatus为1的时候,显示综合评估 -->
													<view class="action_item" @click="inputContent(value,n)"
														v-if="value.quesStatus == 1">
														录入综合评估
													</view>
													<view class="action_item" @click="JobAction(value)"
														v-if="n.planStatus == 0">
														执行
													</view>
													<view class="action_item" @click="ignore(value)"
														v-if="n.planStatus == 0">
														忽略
													</view>
												</view>
											</view>
										</view>


										<view class="rule_content_show" @click="showContent(n,key)">
											{{n.arrow== 'arrow-down' ? '点击展开' : '点击收起'}} <u-icon class="m-l-8"
												:name="n.arrow" color="#666"></u-icon>
										</view>

										<!-- <view class="rule_content_action">
											<view class="edit" >
												已完成：<span style="color: #333;">{{n.jobCompleteNum}}</span>
											</view>
											<view class="del" >
												完成率：<span style="color: #333;">{{n.jobCompleteRate}}</span>
											</view>
										</view> -->
									</view>
								</view>
							</view>
						</view>
						<view class="job_empty" v-if="JobEmpty">
							<view class="">
								<u-image width="335rpx" height="320rpx" :src="actionImg"></u-image>
							</view>
							<view class="empty_text">
								{{emptyText}}
							</view>
						</view>
					</view>

					<view class="jilu" v-show="currentNav == 2">
						<view class="jilu_box" v-for="(n,key) in jiluList" @click="goSuifangDetails(n)">
							<view class="jilu_time">
								{{n.jobStartTime}}
							</view>
							<view class="jilu_title">
								<view class="rule_content_title">
									<view class="base_icon zhouqi"
										:class="{'zhouqi':n.jobType == 2,'dingshi':n.jobType == 1}">
										{{n.jobType == 1 ? '定时' : '周期'}}
									</view>
									<view class="m-l-10">
										{{cultString(n.jobName,14)}}
									</view>
								</view>
							</view>
							<view class="jilu_top_title">
								随访内容
							</view>
							<view class="jilu_content">
								{{cultString(n.jobContent,14) }}
							</view>
							<view class="jilu_top_title">
								随访记录
							</view>
							<view class="jilu_content">
								{{cultString(n.recordDesc,14) }}
							</view>
						</view>
						<view class="job_empty" v-if="RecordEmpty">
							<view class="">
								<u-image width="335rpx" height="320rpx" :src="actionImg"></u-image>
							</view>
							<view class="empty_text">
								{{emptyText}}
							</view>
						</view>
					</view>

				</view>
			</view>
		</view>
		<u-popup v-model="showMark" border-radius="40" mode="top" :safe-area-inset-bottom="true"
			:mask-close-able="false">
			<mark-list-dtl ref="markList" @closeMark="closeMark" @Markconfirm="Markconfirm"></mark-list-dtl>
		</u-popup>
		<go-nav></go-nav>

		<u-modal v-model="show" :show-title="false" :content="content"
			:content-style="{'fontSize':'32rpx','lineHeight': '1.5','fontWeight':'bold'}" cancel-color="#333333"
			:show-cancel-button="true" confirm-color="#4DC0D9" @confirm="confirm" @cancel="cancel"
			:cancel-style="{'borderRight':'1px solid #f8f8f8'}">
		</u-modal>

		<u-modal v-model="showAbort" :show-title="false" content="计划终止后,将不再以此随访计划作为该患者的诊后随访任务 ，确定要终止该计划吗？"
			:content-style="{'fontSize':'32rpx','lineHeight': '1.5','fontWeight':'bold'}" cancel-color="#333333"
			:show-cancel-button="true" confirm-color="#4DC0D9" @confirm="confirmAbort" @cancel="cancelAbort"
			:cancel-style="{'borderRight':'1px solid #f8f8f8'}">
		</u-modal>

		<bottom-button text="新建随访计划" @confirm="newConfirm" :inactive="false"></bottom-button>
	</view>
</template>

<script>
	import {
		getPatientDetails,
		editCustomerTag,
		getCustomerInfo,
		tagedList,
		getUserCorpIdAndAgentId,
		getBaseInfo,
		customergetCustomerAffiliateInfo,
		executeOrIgnoreFollowupPlanJob,
		updFollowupPlanCustomerStatus
	} from '@/api/index'
	import register from '@/utils/register'
	export default {
		data() {
			return {
				Male: require('@/static/icon/Gender _ Male@2x.png'),
				Female: require('@/static/icon/Gender _ Female@2x.png'),
				MarkList: [],
				showMark: false, //标签弹层
				shadowStyle: {
					backgroundImage: "none",
					paddingTop: "0",

				},
				lists: [
					// {
					// 	name: "糖尿病患者",
					// 	id: "1"
					// }
				],
				cuId: '', //患者id
				id: '', //标签回显ID使用
				aiType: ['未知', '微信', '企业微信'],
				//sex:['男','女','未知'],
				data: '',
				editTagIdList: [], //批量选择的标签
				externalUserIdList: [], //打标签人，因为详情只有一人，所以加载时push就行
				externalUserId: '', //外部人员ID
				entry: '',
				agentId: '',
				userId: '',
				corpId: '',
				listNav: [{
					name: '基础信息'
				}, {
					name: '随访计划'
				}, {
					name: '随访记录',
				}],
				currentNav: 0,
				jobList: [{ //添加任务规则页面
						jobStartTime: '2024-06-17 10:26',
						jobType: '1', //任务类型  1定时 2周期
						jobName: '鼻咽癌康复训练定期跟踪', //任务名称
						jobContent: '【随访】您好，请认真填写康复训练问卷调查，以便于我们根据随访内容对您的康复情况做出解读并制...', //任务内容
						jobCompleteNum: '1', //已完成
						jobCompleteRate: '16.6%', //完成率
						arrow: 'arrow-down'
					},
					{ //添加任务规则页面
						jobStartTime: '2024-06-15 10:26',
						jobType: '2', //任务类型  1定时 2周期
						jobName: '鼻咽癌康复训练II期跟踪', //任务名称
						jobContent: '【随访】您好，请认真填写康复训练问卷调查，以便于我们根据随访内容对您的康复情况做出解读。', //任务内容
						jobCompleteNum: '2', //已完成jobCompleteNum				
						jobCompleteRate: '33.3%', //完成率
						arrow: 'arrow-down'
					}
				],
				jiluList: [
					// { //添加任务规则页面
					// 	jobStartTime: '2024-06-17 10:26',
					// 	jobType: '1', //任务类型  1定时 2周期
					// 	jobName: '鼻咽癌康复训练定期跟踪', //任务名称
					// 	jobContent: '【随访】您好，请认真填写康复训练问卷调查，以便于我们根据随访内容对您的康复情况做出解读并制...', //任务内容
					// 	jobCompleteNum: '1', //已完成
					// 	recordDesc: '你好，这是随访记录信息', //随访记录
					// }
				],
				setpTime: require('@/static/icon/Time node@2x.png'),
				stop: require('@/static/icon/stop.png'),
				show: false,
				content: '',
				showAbort: false, //计划终止
				currentProject: '', //当前终止任务所选任务
				actionImg: require('@/static/img/No_follow.png'),
				emptyText: '',
				JobEmpty: false,
				RecordEmpty: false,
				currentObj: '',
				baseInfo: '', //基础信息
			}
		},
		computed: {
			phoneNum(num) {
				return (num) => {
					if (num) {
						return num.slice(0, 3) + '****' + num.slice(7, 11)
					} else {
						return num
					}
				}
			},
			showName() {
				if (this.data.name) return this.data.name
				return this.data.nickName ? this.data.nickName : ''
			},
			timeSerious(time) {
				return (time) => {
					const date = new Date(time)
					const year = date.getFullYear();
					const month = String(date.getMonth() + 1).padStart(2, '0'); // 月份是从0开始的，所以要加1  
					const day = String(date.getDate()).padStart(2, '0');
					const hours = String(date.getHours()).padStart(2, '0');
					const minutes = String(date.getMinutes()).padStart(2, '0');
					return `${year}-${month}-${day} ${hours}:${minutes}`;
				}
			},
			cultString(val, num) {
				return (val, num) => {
					if (val) {
						let myString = val.toString()
						if (val.length > num) {
							return val.slice(0, num) + '...'
						} else {
							return val
						}
					} else {
						return ''
					}

				}
			},
			state(num) {
				return (num) => {
					switch (num) {
						case 0:
							return '待开始'
						case 1:
							return '进行中'
						case 2:
							return '已完成'
						case -1:
							return '已关闭'
						case -2:
							return '已过期'
						default:
							return '待开始'
					}
				}
			}
		},
		onLoad(obj) {
			let store = this.$store.state.doc.tohuanDetailsParams
			if (store.id) {
				this.id = store.id
			}
			if (obj.cuId) {
				this.cuId = obj.cuId
			}
			if (store.cuId) {
				this.cuId = store.cuId
			} else {
				this.getOutId()
			}
			//this.getNavList()
		},
		onShow() {
			let store = this.$store.state.doc.tohuanDetailsParams
			this.clearVuex()
			this.data = uni.getStorageSync('patientDetails')
			if (store.cuId) {
				this.init()
			}
			//this.$refs.markList.$emit('startRequest')
		},
		watch: {
			currentNav: {
				handler(cur, old) {
					this.getNavList()
				},
				immediate: false
			}
		},
		methods: {
			async getNavList() {
				let teamId = uni.getStorageSync('myTeam').data?.id || 0
				let res = await customergetCustomerAffiliateInfo(
					this.currentNav + 1,
					this.data.externalUserId,
					teamId
				)
				if (res.code == 200) {
					if (this.currentNav == 0) { //基础信息
						if (res.data && res.data.length > 0) {
							this.baseInfo = res.data[0]
							console.log(this.baseInfo);
						}
					}
					if (this.currentNav == 1) { //随访计划在返回参数里加个展开参数
						this.jobList = res.data.map(v => {
							v.arrow = 'arrow-down'
							return v
						})
						if (res.data.length == 0) { //暂无随访计划
							this.JobEmpty = true
							this.actionImg = require('@/static/img/No_follow.png')
							this.emptyText = '暂无随访计划'
						}
					}
					if (this.currentNav == 2) {
						this.jiluList = res.data
						if (res.data.length == 0) { //暂无随访记录
							this.RecordEmpty = true
							this.actionImg = require('@/static/img/No_team@2x.png')
							this.emptyText = '暂无随访记录'
						}
					}
				}
				//console.log(res, 'aaa');
			},
			stopProject(obj) {
				//console.log(obj);
				this.currentProject = obj
				this.showAbort = true
			},
			async confirmAbort() { //计划终止模态框
				let params = {
					planId: this.currentProject.planId,
					externalUserId: this.data.externalUserId
				}
				let res = await updFollowupPlanCustomerStatus(params)
				if (res.code == 200) {
					this.getNavList()
					this.$u.toast('计划终止成功', 3000)
				} else {
					this.$u.toast(res.msg, 3000)
				}
				// let res = await cancelJob(this.planId) //id
			},
			cancelAbort() { //取消计划终止

			},
			async look(obj) { //查看问卷
				if (obj.quesResultUrl) {
					window.location.href = obj.quesResultUrl
				}
				//console.log(obj);
				//console.log(obj, list, 'sss');
				// this.$store.commit('SHOWJOBLISTALL', list.followupPlanJobList)
				// if (obj.jobType == 1) this.$store.commit('JOBTYPEShow', '定时任务')
				// if (obj.jobType == 2) this.$store.commit('JOBTYPEShow', '周期任务')
				// let res = await this.$store.dispatch('editJobList', obj.jobName)
				//if (res.find) {
				// uni.navigateTo({
				// 	url: `/pages/follow/rulejobview?edit=1&jobName=${obj.jobName}`
				// })
				//}
			},
			inputContent(obj, topData) { //录入综合评估
				// console.log(obj,topData);
				// return
				uni.navigateTo({
					url: `/pages/index/pinggu?id=${obj.id}&externalUserId=${this.data.externalUserId}&planId=${topData.planId}&quesResultId=${obj.quesResultId}`
				})
			},
			async JobAction(obj) { //执行
				let params = {
					executeOrIgnore: 'execute',
					jobId: obj.id
				}
				let res = await executeOrIgnoreFollowupPlanJob(params)
				if (res.code == 200) {
					uni.showLoading({
						title: "加载数据中"
					})
					setTimeout(async () => {
						// uni.hideLoading()
						// this.clearPageStatus()
						// await this.getTeam()
						this.getNavList()
					}, 3000)
				}
				//console.log(obj);
			},
			ignore(obj) { //忽略
				this.currentObj = obj
				this.show = true
				this.content = `忽略后将不再对该患者执行“${obj.jobName}”任务，确定要忽略该任务吗？`
			},
			async confirm() { //忽略弹窗
				let params = {
					executeOrIgnore: 'ignore',
					jobId: this.currentObj.id
				}
				let res = await executeOrIgnoreFollowupPlanJob(params)
				if (res.code == 200) {
					this.getNavList()
				}
			},
			cancel() { //取消忽略

			},
			showContent(obj, key) { //展开折叠
				this.jobList[key].arrow == 'arrow-up' ? this.jobList[key].arrow = 'arrow-down' : this.jobList[key].arrow =
					'arrow-up'

			},
			changeNav(index) {
				this.currentNav = index;
			},
			async getOutId() {
				await this.getConfig()
				await this.getContext()
				//let t = await this.getContext()
				//if (!t) return //如果群聊进入，下面就没必要执行了
			},
			async getConfig() {
				let res = await getBaseInfo()
				if (res.code == 200) {
					this.agentId = res.user.agentId
					this.corpId = res.user.corpId
				} else {
					this.$u.toast(res.msg)
				}
				//console.log(res, corpId, agentId, 'config');
			},
			async getContext() {
				await register(['getContext', 'sendChatMessage', 'getCurExternalContact'])
				this.$ww.getContext({
					success: (res) => {
						console.log(res);
						this.entry = JSON.stringify(res.entry); //返回进入小程序的入口类型
						if (res.entry == 'group_chat_tools') {
							this.$u.toast('群聊暂不支持获得患者信息')
							return false
						}
						this.outID()
						var shareTicket = res.shareTicket;
					}
				})
			},
			getContexts() { //收集
				this.$ww.getContext({
					success: (res) => {
						console.log(res, 'res');
						this.entry = JSON.stringify(res.entry); //返回进入小程序的入口类型
						if (res.entry == 'normal') {
							this.$u.toast(' 请到会话框执行该操作！')
							return
						}
						this.sendToMessageBox() //分享到聊天框
						var shareTicket = res.shareTicket;
					},
					fail: (res) => {
						//this.$u.toast('此功能，需从侧边栏进入才能确定发送患者，正常使用功能！！！')
						console.log(res);
					}
				})
			},
			sendToMessageBox() {
				this.$ww.sendChatMessage({
					msgtype: "news", //消息类型，必填
					enterChat: false, //为true时表示发送完成之后顺便进入会话，仅移动端3.1.10及以上版本支持该字段
					news: {
						link: `https://wx.precare.cn/pages/index/index`, //H5消息页面url 必填
						title: '电子健康卡授权登录', //H5消息标题
						desc: '请授权登录，以便我们为您提供更精准的服务！', //H5消息摘要
						imgUrl: require('@/static/img/qr_icon.png'), //H5消息封面图片URL
					},
					success: (res) => {
						this.message = JSON.stringify(res)
						this.$u.toast('发送成功！！！')
						//todo:
					},
					fail: (res) => {
						this.showEorror = JSON.stringify(res)
						this.$u.toast(' 请到会话框执行该操作！')
						console.log(res);
					}
				});
			},
			async action() {
				let params = {
					userId: '',
					externalUserId: '',
					corpId: '',
				}

				params.userId = uni.getStorageSync('userinfo').user.wechatUserId
				if (this.corpId) params.corpId = this.corpId
				params.externalUserId = this.externalUserId
				this.externalUserIdList = []
				this.lists = []
				console.log(888, params);
				let res = await getCustomerInfo(params)
				if (res.code == 200) {
					this.data = res.data
					this.data.type = this.aiType[this.data.type]
					uni.setStorageSync('patientDetails', res.data)
					if (res.data.id) this.id = res.data.id
					//console.log(this.data.id,'fenxiangId');
					this.getNavList()
					this.externalUserIdList.push(res.data.externalUserId)
					//this.getMarkedList()
					// if(this.data.sex){
					// 	this.data.sex = this.sex[Number(this.data.sex)]
					// }
					if (this.data.tagName?.length > 0) {
						this.lists = this.data.tagName?.split(',').map((v, k) => {
							return {
								name: v,
								id: k
							}
						})
					}

				} else {
					this.$u.toast(res.msg, 5000)
				}
			},
			outID() { //查找外部人员id
				return new Promise(resolve => {
					this.$ww.getCurExternalContact({
						success: (res) => {
							let userId = res.userId //返回当前外部联系人userId
							this.externalUserId = res.userId
							console.log(res, 1123);
							this.action()
							resolve()
						},
						fail: (res) => {
							this.$u.toast(JSON.stringify(res))
							console.log(res);
							resolve()
						}
					})
				})
			},
			async init() {
				// await this.getConfig()
				this.externalUserIdList = []
				this.lists = []
				let res = await getPatientDetails(this.cuId)
				if (res.code == 200) {
					this.data = res.data
					this.getNavList()
					this.data.type = this.aiType[this.data.type]
					uni.setStorageSync('patientDetails', res.data)
					this.externalUserIdList.push(res.data.externalUserId)
					// if(this.data.sex){
					// 	this.data.sex = this.sex[Number(this.data.sex)]
					// }

					if (this.data.tagName?.length > 0) {
						this.lists = this.data.tagName?.split(',').map((v, k) => {
							return {
								name: v,
								id: k
							}
						})
					}
				}
				//console.log(this.data);
			},
			async getMarkedList() {
				//teamId
				//let teamId = uni.getStorageSync('myTeam').data.id
				let res = await tagedList({
					'cuId': this.cuId
				})
				if (res.data.length > 0) {
					let obj = Object.values(res.data)
					obj.forEach(v => {
						v.tagList.forEach(val => {
							//console.log(val,'000');
							val['check'] = JSON.parse(val.isCheck)
						})
					})
					this.$refs.markList.list = obj
					//console.log(this.$refs.markList.list,'taged');
				} else {
					this.$refs.markList.empty = true
				}
			},
			closeMark(val) {
				this.MarkList = val //选中标签  
				this.showMark = false
			},
			Markconfirm(list) {
				this.editTagIdList = []
				this.MarkList = this.$u.deepClone(list) //选中标签列表
				const markChoose = this.MarkList.markChoose
				markChoose.map(v => {
					this.editTagIdList.push(v.tagId)
				})
				//console.log(this.editTagIdList);
				this.postMark() //打标签
				this.showMark = false
			},
			async openMarkList() {
				this.showMark = true
				this.getMarkedList()
			},
			async postMark() {
				const params = {
					'editTagIdList': this.editTagIdList,
					'externalUserIdList': this.externalUserIdList,
					'flag': 'single'
				}
				// console.log(params);
				// return
				let res = await editCustomerTag(params)
				if (res.code == 200) {
					this.init()
				}
				//console.log(res);
			},
			dengji() {
				return
				uni.navigateTo({
					url: '/pages/patient/dengji'
				})
			},
			newConfirm() {
				uni.navigateTo({
					url: `/pages/follow/newproject?externalUserId=${this.data.externalUserId}`
				})
			},
			goSuifangDetails(obj) { //随访记录详情
				const externalUserId = this.data.externalUserId
				// console.log(obj);
				// return
				uni.navigateTo({
					url: `/pages/patient/suifangdetails?externalUserId=${externalUserId}&planJobId=${obj.planJobId}`
				})
			},
			clearVuex() {
				this.$store.commit('PICKTemplate', '') //清空选择模板
				this.$store.commit('SUIFANGuserSelected', '')
				this.$store.commit('SUIFANGhuanzheSelected', '')
				this.$store.commit('JOBTYPEShow', '定时任务')
				this.$store.commit('JobFORMClear', '')
				this.$store.commit('SHOWJOBLISTALL', [])
			},
		}
	}
</script>

<style lang="scss" scoped>
	.mains {
		position: absolute;
		width: 100%;
		height: 100vh;
		background-color: #f8f8f8;

		.zhingkeitemlist {
			.zhingkeitemname {
				font-weight: 400;
				line-height: 50rpx;
				padding-left: 20rpx;
				padding-right: 20rpx;
				margin-right: 12rpx;
				margin-bottom: 12rpx;
				background: #F8F8F8;
				border-radius: 8rpx 8rpx 8rpx 8rpx;
				text-indent: 0;
				font-weight: 400;
				font-size: 26rpx;
				color: #333333;

			}

		}

		.huanzhedetail {
			background-color: #F8F8F8;
			padding-bottom: 100rpx;
			overflow: hidden;
			//padding-top: 180rpx;

			.biaoqian {
				width: 702rpx;
				// padding-bottom: 20rpx;
				background: #FFFFFF;
				border-radius: 20rpx 20rpx 20rpx 20rpx;
				margin: 0 auto;
				margin-top: 20rpx;

				.nav_list {
					padding-top: 12rpx;
					//margin-bottom: -8rpx;
					width: 100%;
					border-bottom: 1px solid #eee;
				}

				.base {}

				.jihua {
					.rule_box {
						background-color: #ffffff;
						padding-bottom: 700rpx;
						padding-top: 24rpx;

						.rule_card {
							//padding-top: 24rpx;
							padding-left: 24rpx;
							//height: 204rpx;
							display: flex;
							flex-direction: column;
							//align-items: center;
							justify-content: center;

							.rule_step {
								.dot {
									display: flex;
									align-items: center;

									.time_title {
										margin-left: 8rpx;
										font-weight: 500;
										font-size: 32rpx;
										color: #999999;
										//line-height: 1.5;
									}

									.stop {
										flex: 1;
										padding-right: 24rpx;
										display: flex;
										justify-content: flex-end;
									}
								}
							}

							.rule_content {
								//padding-left: 40rpx;
								padding-left: 24rpx;
								margin-left: 5px;
								//height: 266rpx;
								border-left: 1px dashed #ccc;
								font-weight: bold;
								font-size: 34rpx;
								color: #212121;
								line-height: 42rpx;

								.rule_content_title {
									margin-top: 6rpx;
									display: flex;
									align-items: center;

									.base_icon {
										display: flex;
										align-items: center;
										justify-content: center;
										padding: 4rpx 6rpx 6rpx 6rpx;
										width: 70rpx;
										height: 40rpx;
										background: #FF8D07;
										font-weight: 500;
										font-size: 24rpx;
										color: #FFFFFF;
										text-align: center;
										line-height: 28rpx;
										border-radius: 8rpx;
									}

									.zhouqi {
										background: #FF8D07;
									}

									.dingshi {
										background-color: #4DC0D9;
									}

									.base_status {
										font-weight: bold;
										font-size: 26rpx;
										color: #333333;
										line-height: 40rpx;
										width: 94rpx;
										height: 40rpx;
										background: #F2F2F2;
										border-radius: 8rpx 8rpx 8rpx 8rpx;
										padding: 2rpx 8rpx;
										text-align: center;
										display: flex;
										justify-content: center;
										align-items: center;
									}

									.blue {
										color: #189AFF;
										background: #E5F4FF;
									}

									.green {
										color: #36B278;
										background: #E2FFF2;
									}

									.gray {
										color: #999999;
										background-color: #F1F2F4;
									}
								}

								.card_inner_box {
									width: 606rpx;
									height: 252rpx;
									background: #F8F8F8;
									border-radius: 20rpx 20rpx 20rpx 20rpx;
									margin-top: 24rpx;

									.card_inner_box_time {
										font-weight: 500;
										font-size: 28rpx;
										color: #999999;
										line-height: 33rpx;
										padding: 24rpx 24rpx 8rpx 24rpx;
									}

									.card_inner_box_title {
										font-weight: 500;
										font-size: 32rpx;
										color: #212121;
										line-height: 38rpx;
										margin-left: 24rpx;

										.rule_content_title {
											margin-top: 6rpx;
											display: flex;
											align-items: center;

											.base_icon {
												display: flex;
												align-items: center;
												justify-content: center;
												padding: 4rpx 6rpx 6rpx 6rpx;
												width: 70rpx;
												height: 40rpx;
												background: #FF8D07;
												font-weight: 500;
												font-size: 24rpx;
												color: #FFFFFF;
												text-align: center;
												line-height: 28rpx;
												border-radius: 8rpx;
											}

											.zhouqi {
												background: #FF8D07;
											}

											.dingshi {
												background-color: #4DC0D9;
											}
										}
									}

									.card_inner_box_content {
										margin-left: 24rpx;
										margin-top: 12rpx;
										padding-right: 24rpx;
										font-size: 30rpx;
										color: #666666;
										line-height: 1.5;
									}

									.card_inner_box_action {
										font-weight: 500;
										font-size: 28rpx;
										color: #4DC0D9;
										line-height: 33rpx;
										display: flex;
										justify-content: flex-end;
										margin-top: 20rpx;
										margin-right: 24rpx;

										.action_item {
											margin-left: 48rpx;
										}
									}


								}

								.rule_content_details {
									margin-top: 12rpx;
									padding-right: 24rpx;
									font-size: 30rpx;
									color: #666666;
									line-height: 1.5;
								}

								.rule_content_show {
									margin-top: 16rpx;
									margin-bottom: 60rpx;
									font-weight: 500;
									font-size: 30rpx;
									color: #666666;
									line-height: 36rpx;
								}

								.rule_content_action {
									margin: 20rpx 24rpx 60rpx 0;
									display: flex;
									//justify-content: flex-end;
									font-weight: 500;
									font-size: 30rpx;
									color: #666;
									line-height: 1.5;

									.edit {
										margin-right: 48rpx;
									}

									.del {}
								}
							}
						}
					}
				}

				.jilu {
					.jilu_box {
						margin: 24rpx;
						padding: 24rpx;
						background-color: #F8F8F8;
						border-radius: 20rpx;

						.jilu_time {
							font-weight: 500;
							font-size: 28rpx;
							color: #999999;
							line-height: 33rpx;
						}

						.jilu_title {
							.rule_content_title {
								margin-top: 6rpx;
								display: flex;
								align-items: center;
								border-bottom: 1px solid #ccc;
								padding-bottom: 24rpx;

								.base_icon {
									display: flex;
									align-items: center;
									justify-content: center;
									padding: 4rpx 6rpx 6rpx 6rpx;
									width: 70rpx;
									height: 40rpx;
									background: #FF8D07;
									font-weight: 500;
									font-size: 24rpx;
									color: #FFFFFF;
									text-align: center;
									line-height: 28rpx;
									border-radius: 8rpx;
								}

								.zhouqi {
									background: #FF8D07;
								}

								.dingshi {
									background-color: #4DC0D9;
								}
							}
						}

						.jilu_top_title {
							margin-top: 24rpx;
							padding-left: 24rpx;
							font-weight: bold;
							font-size: 28rpx;
							color: #333333;
							line-height: 33rpx;
							position: relative;
						}

						.jilu_top_title::before {
							content: '';
							position: absolute;
							top: 0;
							left: 0;
							width: 8rpx;
							height: 32rpx;
							background: #4DC0D9;
							border-radius: 0rpx 200rpx 200rpx 0rpx;
						}

						.jilu_content {
							margin-top: 12rpx;
						}
					}
				}

				.jichuitem {
					width: 654rpx;
					margin: 0 auto;
					border-bottom: 1rpx solid #eee;
					display: flex;
					padding-top: 30rpx;
					padding-bottom: 30rpx;
					justify-content: space-between;

					.jichuiteml {
						//font-weight: 500;
						font-size: 32rpx;
						color: #212121;
					}

					.jichuitemr {
						font-weight: 500;
						font-size: 32rpx;
						color: #999999;
						width: 500rpx;
						text-align: right;
					}
				}

				.biaoqiantop {
					width: 654rpx;
					margin: 0 auto;
					display: flex;
					justify-content: space-between;
					align-items: center;

					.biaoqiantopl {
						font-weight: bold;
						font-size: 34rpx;
						color: #212121;
						line-height: 80rpx;
					}

					.biaoqiantopr {
						display: flex;

						.biaoqiantoprtit {
							font-weight: 500;
							font-size: 30rpx;
							color: #4DC0D9;
							line-height: 80rpx;
						}

						.biaoqiantoprlogo {
							color: #4DC0D9;
							font-size: 34rpx;
							//margin-top: 23rpx;
							line-height: 80rpx;
						}
					}
				}
			}

			.pepinfo {
				width: 702rpx;
				padding-bottom: 20rpx;
				background: #FFFFFF;
				border-radius: 20rpx 20rpx 20rpx 20rpx;
				margin: 0 auto;
				margin-top: 20rpx;

				.pepinfomain {
					width: 654rpx;
					margin: 0 auto;

					.pepname {
						font-weight: bold;
						font-size: 34rpx;
						color: #212121;
						line-height: 100rpx;

						span {
							color: #36B278;
						}
					}

					.pepmiaoshu {
						display: flex;
						padding-bottom: 30rpx;

						.pepage {
							display: flex;
							width: 142rpx;
							height: 56rpx;
							background: #F8F8F8;
							border-radius: 12rpx 12rpx 12rpx 12rpx;

							.sexlogo {
								width: 28rpx;
								height: 28rpx;
								margin-left: 20rpx;
								margin-top: 14rpx;

								image {
									width: 100%;
									height: 100%;
								}
							}

							.agenum {
								font-weight: 500;
								font-size: 28rpx;
								color: #333333;
								line-height: 56rpx;
								margin-left: 10rpx;
							}

						}

						.suoshu {
							//width: 264rpx;
							padding: 0 20rpx;
							height: 56rpx;
							background: #F8F8F8;
							border-radius: 12rpx 12rpx 12rpx 12rpx;
							font-weight: 500;
							font-size: 28rpx;
							color: #333333;
							text-align: center;
							line-height: 56rpx;
							//margin-left: 12rpx;
						}
					}

					.juti {
						border-top: 2rpx dashed #eee;
						padding-top: 30rpx;
						font-weight: 500;
						font-size: 28rpx;
						color: #999999;

						span {
							color: #4DC0D9;
						}
					}
				}
			}
		}

		.job_empty {
			padding-top: 126rpx;
			min-height: 100vh;
			padding-bottom: 210rpx;
			display: flex;
			flex-direction: column;
			//justify-content: center;
			align-items: center;

			.empty_text {
				font-weight: 500;
				font-size: 36rpx;
				color: #C7C7C7;
				line-height: 1.5;
				text-align: center;
			}
		}
	}
</style>